package com.mcx;

import com.mcx.modules.common.SpringContextUtil;
import com.mcx.modules.controller.PlayerController;
import com.mcx.modules.controller.WorldMapSceneController;
import com.mcx.modules.controller.WorldMapSceneEntity;
import com.mcx.modules.socket.SocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
public class GameServerRun {
    private static PlayerController playerController;
    private static WorldMapSceneController worldMapSceneController;

    public static void main(String[] args) {
        SpringApplication.run(GameServerRun.class, args);

        ApplicationContext applicationContext = SpringContextUtil.getApplicationContext();
        playerController = applicationContext.getBean(PlayerController.class);
        worldMapSceneController = applicationContext.getBean(WorldMapSceneController.class);

        SocketServer socketServer = new SocketServer();
        socketServer.start();
        InitAllController();
    }

    private static void InitAllController() {
        playerController.Init();
        worldMapSceneController.Init();
    }
}
